package com.shuoyue.ycgk.ui.common;

import com.shuoyue.ycgk.base.BaseModel;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.DayTaget;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;

public interface VipCheckContract {
    interface View extends BaseView {

        void isVip(int isVip);
    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void checkVip(int modelId) {
            apply(model.checkVip(modelId))
                    .subscribe(new ApiSubscriber<Optional<Integer>>(mView, this) {
                        @Override
                        public void onNext(Optional<Integer> dayTagetOptional) {
                            super.onNext(dayTagetOptional);
                            mView.isVip(dayTagetOptional.getIncludeNull());
                        }
                    });
        }


    }

    class Model extends BaseModel {

        Observable<BaseResult<Integer>> checkVip(int modelId) {
            return RetrofitClient.getInstance().getApi().checkVip(modelId);
        }


    }
}
